package com.zhongyewx.teachercert.mvp.model;

import com.zhongyewx.teachercert.api.ZYAPIService;
import com.zhongyewx.teachercert.api.ZYConstants;
import com.zhongyewx.teachercert.framework.okhttp.ZYHttpParameters;
import com.zhongyewx.teachercert.framework.okhttp.ZYOnHttpCallBack;
import com.zhongyewx.teachercert.framework.okhttp.ZYRetrofitUtils;
import com.zhongyewx.teachercert.framework.okhttp.ZYSubscriber;
import com.zhongyewx.teachercert.mvp.contract.ZYHomeFragContact;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class ZYHomeFragModel implements ZYHomeFragContact.IHomeFragModel {

    @Override
    public void getHomeData(ZYOnHttpCallBack<String> callBack) {
        ZYHttpParameters jsonparams = new ZYHttpParameters();
        jsonparams.add("AppId", ZYConstants.APP_ID);
        jsonparams.add("TimeStamp", String.valueOf(System.currentTimeMillis()));
        String req = jsonparams.getJson(jsonparams);
        ZYRetrofitUtils.newInstence()
                .create(ZYAPIService.class)
                .gets("Android.WangXiao.GetAppBanner", "1", req)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.newThread())
                .subscribe(new ZYSubscriber<>(callBack));
    }
}
